Repository navigation
chore(bitcoin): type the Bitcoin handler and use-case leaks - #639
Open
ulissesferreira wants to merge 1 commit into
Open
ulissesferreira wants to merge 1 commit into
ulissesferreira wants to merge 1 commit into
Conversation
ulissesferreira
temporarily deployed
to
default-branch
November 17, 2026 02:30 — with
GitHub Actions
Inactive
|
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Description
Burns down 19 of the Bitcoin Snap's oxlint suppressions across the handler and use-case surface — the smallest of the parallel cleanup units. Everything is type-level or doc-level: the
no-throw-literalthrows in the tests became named non-Errorconstants (the tests deliberately throw non-Errorvalues, so the values themselves are unchanged), theincheck now useshasProperty()from@metamask/utils(own-property check, same narrowing),new Array(length)got its element type, the untypedObject.fromEntrieshelper got an explicit generic implementation with identical output, and theas anytest mocks were replaced with the real entity types.No behaviour changes. The only production logic touched is
reverseMappingincaip.ts, which still produces the same own-key mapping in the same insertion order — it now builds aRecord<To, From>directly instead of returning theanyfromObject.fromEntries.Changes
packages/bitcoin-wallet-snap/src/handlers/HandlerMiddleware.ts— narrowStructError.data(anyvia the library's index signature) to theRecord<string, Json> | undefinedthe error wrapper accepts (no-unsafe-argument)packages/bitcoin-wallet-snap/src/handlers/RpcHandler.ts— element type on the batch results buffer:new Array<T>(items.length)(no-unsafe-assignment)packages/bitcoin-wallet-snap/src/handlers/UserInputHandler.ts—'value' in event→hasProperty(event, 'value')(internal-snaps/no-in-operator)packages/bitcoin-wallet-snap/src/handlers/caip.ts—reverseMappingreturns a typedRecord<To, From>instead ofObject.fromEntries'sany(no-unsafe-return)packages/bitcoin-wallet-snap/src/handlers/mappings.ts— drop the redundantas KeyringAccount['type'](no-unnecessary-type-assertion)packages/bitcoin-wallet-snap/src/use-cases/AccountUseCases.ts— element type on the batch results buffer (no-unsafe-assignment)packages/bitcoin-wallet-snap/src/use-cases/AccountUseCases.test.ts— named non-Errorthrowables for the cause-handling tests, drop a redundant assertion on the SLIP-10 derivation path (no-throw-literal,no-unnecessary-type-assertion)packages/bitcoin-wallet-snap/src/use-cases/SendFlowUseCases.test.ts— typed mock payloads (Balance,ScriptBuf,SpotPrice,signPsbtreturn type) and a return type on thetoStringstub (no-explicit-any,no-unsafe-argument,explicit-function-return-type)packages/bitcoin-wallet-snap/src/utils/format-btc.test.ts—@vitest-environmentas a line directive instead of an unknown JSDoc tag (jsdoc/check-tag-names)oxlint-suppressions.json— regenerated with--prune-suppressions(19 entries removed across these 9 files, nothing hand-edited)Quality gates
yarn lint:oxlint packages/bitcoin-wallet-snap— clean, 19 suppressions entries removed, no stale entriestsc --noEmit— cleanvitest run— 28 files / 761 tests passoxfmt --check— clean